package com.exception;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

/**
 * Title: Exception
 * Description: TODO
 *
 * @author gejx
 * @version V1.0
 * @date 2021-12-14
 */
@ControllerAdvice
public class Exception {

    @ExceptionHandler({ArithmeticException.class,NullPointerException.class})
    public String testException(Exception ex, Model model){
        model.addAttribute("ex",ex);
        return "error";
    }
}
